Skip to content

fix(git): limit comparisons by literal pathspecs - #242

Merged
1lck merged 9 commits into
mainfrom
devin/2550-git-comparison-pathspec
Dec 2, 2026
Merged

1lck merged 9 commits into
mainfrom
devin/2550-git-comparison-pathspec

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add optional literal pathspecs to git.comparison, preserving whole-repository behavior when omitted.
  • Apply the same repository-relative pathspecs to tracked --name-status output and untracked worktree entries, including Git-compatible normalization of . / empty path components.
  • Resolve pathspec-limited diffs from the containing worktree root when needed, while keeping two-reference comparisons usable in bare repositories.
  • Document the contract and cover file, root, ./file, subdirectory-root, and bare-repository cases with rust/fixtures/git/comparison-pathspecs-v1.json plus regression tests.

Validation:

  • GIT_EDITOR=true cargo test --manifest-path rust/Cargo.toml -p lithe-core git_comparison_pathspecs_limit_tracked_and_untracked_files -- --nocapture
  • cargo clippy --manifest-path rust/Cargo.toml -p lithe-git -p lithe-core --all-targets -- -D warnings
  • scripts/rust-core/verify-rust-core-comments.sh
  • Earlier full validation on the pre-merge branch: GIT_EDITOR=true cargo test --manifest-path rust/Cargo.toml -p lithe-git -p lithe-core, node scripts/rust-core/affected-crates.mjs, node scripts/rust-core/verify-platform-tests.mjs --list, and node --test scripts/rust-core/*.test.mjs

Part of 1lck/Lithe-IDEA#2550. The branch is merged with current Core main so the desktop host can pin one commit without dropping newer Core baseline changes.

Link to Devin session: https://app.devin.ai/sessions/40fd0cdabd664dafadc0c1783ea1cb59
Open in Devin Desktop: https://app.devin.ai/desktop/session/40fd0cdabd664dafadc0c1783ea1cb59?variant=devin
Requested by: @1lck


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review December 1, 2026 04:19
1lck and others added 2 commits December 1, 2026 04:24
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 1 finding. Devin automatically fixed it.

Fixed by Devin (1)
  • Scoped comparisons fail in bare repositories — Fixed by detecting bare repositories before resolving a worktree root; scoped two-reference comparisons now run in the bare repository, with regression coverage for HEAD~1..HEAD limited to z-target.txt.

View findings in Devin Review · Follow Devin's work

Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 1 finding. Devin's session did not pick them up; it is left for you to triage below.

View findings in Devin Review · Follow Devin's work

Devin Review

"diff".to_string(),
"--name-status".to_string(),
"--find-renames".to_string(),
"-z".to_string(),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Comparison loses distinct filenames

When tracked filenames contain invalid UTF-8, comparison_diff receives replacement characters from into_command_response. Distinct files can get the same reported path, and includeUntracked then drops one change during deduplication.

Learn more

Git accepts Unix filenames that are not valid UTF-8. In its default name-status output, Git quotes and escapes invalid bytes, preserving the distinction between filenames. The -z output instead sends raw filename bytes. into_command_response replaces invalid bytes before the comparison parser sees them. comparison then uses these altered paths as map keys when includeUntracked is true.

Example: Modify two tracked files named report- followed by byte 0xFE and byte 0xFF, respectively. A whole-repository comparison reports both as report-�. With includeUntracked: true, it reports only one change at that path.

Recommended fix: Parse NUL-delimited comparison output from raw bytes. Preserve invalid filename bytes with a reversible representation, or return an explicit decoding error when a path cannot be represented in the JSON response. Do not deduplicate on a lossy UTF-8 conversion.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@1lck
1lck merged commit c967ea2 into main Dec 2, 2026
12 checks passed
@1lck
1lck deleted the devin/2550-git-comparison-pathspec branch December 2, 2026 08:04

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant